package com.artPreter.mapper;

import com.artPreter.pojo.Artwork;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * <p>
 * 艺术品表 Mapper 接口
 * </p>
 *
 * @author jarvis
 * @since 2024-11-14
 */
@Mapper
public interface ArtworkMapper extends BaseMapper<Artwork> {

    @Select(" select s.* FROM jv_artwork s LEFT JOIN jv_index_item_relative b on s.artwork_id = b.content_id ")
    IPage<Artwork> getNoRelativeArtworkPage(QueryWrapper<Artwork> artworkQueryWrapper);

    @Select("select b.name,b.artwork_id,b.artist_name,b.artwork_num,b.spec,b.price,b.create_srt,b.url,b.artwokt_type,s.sort as sort from jv_index_item_relative s left join jv_artwork b on s.content_id = b.artwork_id ${ew.customSqlSegment} ")
    IPage<Artwork> getIndexRelativeArtworkPage(IPage<Artwork> artworkIPage, @Param(Constants.WRAPPER) Wrapper wrapper);

    @Select(" select s.* FROM jv_artwork s LEFT JOIN jv_artist_relative b on s.artist_id = b.artist_id ${ew.customSqlSegment} ")
    IPage<Artwork> getPageNoRelativeOnline(IPage<Artwork> artworkIPage, @Param(Constants.WRAPPER) Wrapper wrapper);

    @Select(" select s.*,b.name as name,b.artist_name as artistName,b.url as url FROM jv_artwork_depart_relative s LEFT JOIN jv_artwork b on s.artwork_id = b.artwork_id ${ew.customSqlSegment} ")
    IPage<Artwork> getPageRelativeOnline(IPage<Artwork> artworkIPage, @Param(Constants.WRAPPER) Wrapper wrapper);
}
